// pages/user/authentication/authentication.js
const app = getApp();

let api = require('../../../utils/api.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 获取认证接口
   */
  getAuthList: function (e) {
    var that = this;
    var token = wx.getStorageSync('TOKEN');

    api._get('/owner/myself/info', '', token).then(res => {
      if (res.code == 200) {
        var showState = [];
        showState[-1] = '认证未通过';
        showState[0] = '认证审核中';
        showState[1] = '已认证';
        var list = res.result;
        if (list.ownerCompanyState != null) {
          // console.log(list.ownerCompanyState);
          list.showOwnerCompanyState = showState[list.ownerCompanyState];
        } else {
          list.showOwnerCompanyState = '未认证';
        }

        if (list.ownerState != null) {
          list.showOwnerState = showState[list.ownerState];
        } else {
          list.showOwnerState = '未认证';
        }
        that.setData({
          list: list
          // background: res.result
        });

      } else if (res.code > 400) {
        wx.navigateTo({
          url: '../login/login',
        })
      } else {
        wx.showToast({
          title: '网络忙请重试',
          icon: 'none',
        })
      }

    });
  },
  /**
   * 跳转
   */
  navigator: function (e) {
    var that = this;
    var data = that.data.list;
    var state = e.currentTarget.dataset.state;
    if (state == 1 || state == 0) {
      return;
    } else {
      wx.navigateTo({
        url: e.currentTarget.dataset.url,
      })
    }
  }
})